package exam.pdd.S1;

import java.util.*;

public class Main {

    public static int n;
    public static long[] a;
    public static long[] b;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new long[n];
        b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
        }
        Arrays.sort(a);
        Arrays.sort(b);

        long sum = 0L;
        for (int i = 0; i < n; i++) {
            sum += (a[i]-b[i]) * (a[i]-b[i]);
        }

        System.out.println(sum);
    }
}